/*
 * @(#)MaintContactListForm.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.contact.web;



import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

import com.dcivision.contact.bean.ContactList;
import com.dcivision.framework.ApplicationException;
import com.dcivision.framework.TextUtility;
import com.dcivision.framework.bean.AbstractBaseObject;
import com.dcivision.framework.web.AbstractActionForm;

/**
  MaintContactListForm.java

  This class is the for web form purpose.

  @author          Jenny Li
  @company         DCIVision Limited
  @creation date   06/01/2005
  @version         $Revision: 1.9 $
*/

public class MaintContactGroupForm extends AbstractActionForm {

  public static final String REVISION = "$Revision: 1.9 $";

  private String contactListName = null;
  private String description = null;
  private String publicFlag = ContactList.SHARING_TYPE_PUB;
  
  private String[] userIDs = null;
  private String[] userRoles = null;
  private String[] userGroups = null;
  private String[] contactPersonIDs = null;

  public MaintContactGroupForm() {
    super();
  }

  public String getContactListName() { 
    return(this.contactListName);
  }

  public void setContactListName(String contactListName) { 
    this.contactListName = contactListName;
  }

  public String getDescription() { 
    return(this.description);
  }

  public void setDescription(String description) { 
    this.description = description;
  }

  public String getPublicFlag() { 
    return(this.publicFlag);
  }

  public void setPublicFlag(String publicFlag) { 
    this.publicFlag = publicFlag;
  }
  
  public String[] getContactPersonIDs(){
    return this.contactPersonIDs; 
  }
  
  public void setContactPersonIDs(String[] contactPersonIDs){
    this.contactPersonIDs=contactPersonIDs; 
  }
  
  public String[] getUserIDs() {
    return this.userIDs;
  }

  public void setUserIDs(String[] userIDs) {
    this.userIDs = userIDs;
  }

  public String[] getUserRoles() {
    return this.userRoles;
  }

  public void setUserRoles(String[]  userRoles) {
    this.userRoles = userRoles;
  }

  public String[] getUserGroups() {
    return this.userGroups;
  }

  public void setUserGroups(String[] userGroups) {
    this.userGroups = userGroups;
  }
  
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    return super.validate(mapping, request);
  }

  public void reset(ActionMapping mapping, HttpServletRequest request) {
    super.reset(mapping, request);
    this.setID(null);
    this.setContactListName(null);
    this.setDescription(null);
    this.setPublicFlag(ContactList.SHARING_TYPE_PUB);
    this.setRecordStatus(null);
    this.setUpdateCount(null);
    this.setCreatorID(null);
    this.setCreateDate(null);
    this.setUpdaterID(null);
    this.setUpdateDate(null);
  }

  public AbstractBaseObject getFormData() throws ApplicationException {
    ContactList tmpContactList = new ContactList();
    tmpContactList.setID(TextUtility.parseIntegerObj(this.getID()));
    tmpContactList.setContactListName(this.getContactListName());
    tmpContactList.setDescription(this.getDescription());
    tmpContactList.setPublicFlag(this.getPublicFlag());
    tmpContactList.setRecordStatus(this.getRecordStatus());
    tmpContactList.setUpdateCount(TextUtility.parseIntegerObj(this.getUpdateCount()));
    tmpContactList.setCreatorID(TextUtility.parseIntegerObj(this.getCreatorID()));
    tmpContactList.setCreateDate(parseTimestamp(this.getCreateDate()));
    tmpContactList.setUpdaterID(TextUtility.parseIntegerObj(this.getUpdaterID()));
    tmpContactList.setUpdateDate(parseTimestamp(this.getUpdateDate()));
    return tmpContactList;
  }

  public void setFormData(AbstractBaseObject baseObj) throws ApplicationException {
    ContactList tmpContactList = (ContactList)baseObj;
    this.setID(TextUtility.formatIntegerObj(tmpContactList.getID()));
    this.setContactListName(tmpContactList.getContactListName());
    this.setDescription(tmpContactList.getDescription());
    this.setPublicFlag(tmpContactList.getPublicFlag());
    this.setRecordStatus(tmpContactList.getRecordStatus());
    this.setUpdateCount(TextUtility.formatIntegerObj(tmpContactList.getUpdateCount()));
    this.setCreatorID(TextUtility.formatIntegerObj(tmpContactList.getCreatorID()));
    this.setCreateDate(formatTimestamp(tmpContactList.getCreateDate()));
    this.setUpdaterID(TextUtility.formatIntegerObj(tmpContactList.getUpdaterID()));
    this.setUpdateDate(formatTimestamp(tmpContactList.getUpdateDate()));
  }
}
